home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Utilities / Programming / Snippets 2.4 / Snippets / Snippets.rsrc / TEXT_401_1.txt < prev    next >
Encoding:
Text File  |  1996-01-21  |  21.8 KB  |  916 lines

  1. /**********************************************************************
  2.  
  3.     Main.cp
  4.  
  5. ***********************************************************************/
  6.  
  7. /*
  8.     Starter Application 2.1
  9.  
  10.     Requires Argus Libraries 2.1
  11.     
  12.     Funct_()   All functions and sub-routines in Main.cp are identified
  13.                with an underscore '_' at the end of the function name.
  14.                This hopefully helps to identify program functions 
  15.                from Toolbox calls.
  16.  
  17.     MyFunct()  All other functions are identified by "My" at the
  18.                beginning of the function name.
  19.  
  20. */
  21.  
  22. /********** Standard Includes */
  23. #include <Types.h>
  24. #include <Quickdraw.h>
  25. #include <Controls.h>
  26. #include <Desk.h>
  27. #include <Dialogs.h>
  28. #include <DiskInit.h>
  29. #include <Editions.h>
  30. #include <EPPC.h>
  31. #include <Events.h>
  32. #include <Fonts.h>
  33. #include <GestaltEqu.h>
  34. #include <Lists.h>
  35. #include <Menus.h>
  36. #include <OSEvents.h>
  37. #include <TextEdit.h>
  38. #include <ToolUtils.h>
  39. #include <Traps.h>
  40. #include <AppleEvents.h>
  41. #include <Balloons.h>
  42.  
  43. #include "Fn_Prototypes.h"
  44. #include "ArgusAbout.h"
  45. #include "ArgusHelp.h"
  46. #include "MainWindow.h"
  47. #include "SampleDialog.h"
  48. #include "SampleList.h"
  49.  
  50. /********** Defines */
  51. #define BASE_RES             400
  52. #define NIL_PTR              0L
  53. #define MOVE_TO_FRONT        -1L
  54. #define LEAVE_IT             FALSE
  55. #define DRAG_THRESHOLD       30
  56. #define REMOVE_ALL_EVENTS    0
  57. #define MIN_SLEEP            60L
  58. #define NIL_MOUSE_REGION     0L
  59. #define WNE_TRAP_NUM         0x60
  60. #define UNIMPL_TRAP_NUM      0x9F
  61. #define NIL_STR              "\p"
  62. #define MIN_SYS_VERSION      0x700  // identify min sys req
  63. #define HELP_MENU            "\pApplication Help..."
  64.  
  65. /********** General */
  66. #define ZERO             0
  67. #define FIRST            1
  68. #define SECOND           2
  69. #define THIRD            3
  70. #define FOURTH           4
  71.  
  72. #define LINE_FEED        10
  73. #define RETURN           13
  74. #define SPACE            32
  75. #define TAB              9
  76.  
  77. /********** Window definitions */
  78. #define WIND_LEFT        10
  79. #define WIND_TOP         50
  80. #define WIND_OFFSET      10
  81.  
  82. /*
  83.     The following define statements cross-reference
  84.     names with resource ID numbers.
  85. */
  86.  
  87. /********** Menus */
  88. #define APPLE_MENU     BASE_RES
  89. #define FILE_MENU      BASE_RES + 1
  90. #define EDIT_MENU      BASE_RES + 2
  91.  
  92. /********** Error Strings */
  93. #define GENERAL_ERR    900
  94. #define BAD_SYS        901
  95. #define N0_RESOURCE    902
  96.  
  97. /********** Apple Menu Stuff */
  98. #define ABOUT          1
  99.  
  100. /********** File Menu Stuff */
  101. #define NEW            1
  102. #define CLOSE          2
  103. #define QUIT           3
  104.  
  105. /********** Edit Menu Stuff */
  106. #define UNDO           1
  107. #define CUT            3
  108. #define COPY           4
  109. #define PASTE          5
  110. #define CLEAR          6
  111.  
  112. /********** Structures */
  113. struct SysConfigRec
  114. {
  115.     Boolean hasGestalt;
  116.     Boolean hasWNE;
  117.     Boolean hasColorQD;
  118.     Boolean hasAppleEvents;
  119.     Boolean hasEditionMgr;
  120.     Boolean hasHelpMgr;
  121.  
  122.     long    sysVersion;
  123. };
  124.  
  125. /********** Variables */
  126. Boolean             gDone;
  127. EventRecord         gTheEvent;
  128. MenuHandle          gAppleMenu;
  129. MenuHandle          gFileMenu;
  130. MenuHandle          gEditMenu;
  131. Rect                gDragRect;
  132. short               gAppResourceFile;
  133. struct SysConfigRec gSysConfig;
  134. int                 gNewWindowLeft = WIND_LEFT;
  135. int                 gNewWindowTop = WIND_TOP;
  136.  
  137. /********** Prototypes */
  138. void main( void );
  139. void ToolBoxInit_( void );
  140. Boolean TrapAvailable_( short tNumber, TrapType tType );
  141. static void GetSysConfig_( void );
  142. void MenuBarInit_( void );
  143. void SetUpDragRect_( void );
  144. void MainLoop_( void );
  145. void HandleEvent_( void );
  146. void HandleMouseDown_( void );
  147. void AdjustMenus_( void );
  148. int  IsDAWindow_( WindowPtr whichWindow );
  149. void HandleMenuChoice_( long int menuChoice );
  150. void HandleAppleChoice_( int theItem );
  151. void HandleFileChoice_( int theItem );
  152. void HandleEditChoice_( int theItem );
  153. void NewWindow_( void );
  154. void Quit_( void );
  155.  
  156. /********** main */
  157.  
  158. void main( void )
  159. {
  160.     ToolBoxInit_();
  161.     GetSysConfig_();
  162.     
  163.     if( gSysConfig.hasAppleEvents )
  164.         FnAE_InitAE();
  165.     
  166.     MenuBarInit_();
  167.     SetUpDragRect_();
  168.     
  169.     if( !gSysConfig.hasAppleEvents )
  170.         /* put OpenApp procedure here */
  171.         MyCreateWindow( BASE_RES, NIL_PTR, (WindowPtr)MOVE_TO_FRONT,
  172.             WIND_TOP, WIND_LEFT, WIND_OFFSET, N0_RESOURCE );
  173.  
  174.     MainLoop_();
  175. }
  176.  
  177.  
  178. /********** ToolBoxInit */
  179.  
  180. void ToolBoxInit_( void )
  181. /*
  182.     Standard initialization procedure per IM:Overview p4-75
  183. */
  184. {
  185.     MaxApplZone();
  186.     MoreMasters();
  187.     
  188.     InitGraf( &qd.thePort );
  189.     InitFonts();
  190.     InitWindows();
  191.     InitMenus();
  192.     TEInit();
  193.     InitDialogs( NIL_PTR );
  194.     
  195.     FlushEvents( everyEvent, REMOVE_ALL_EVENTS );    
  196.     InitCursor();
  197. }
  198.  
  199.  
  200. /********** TrapAvailable */
  201.  
  202. Boolean TrapAvailable_( short tNumber, TrapType tType )
  203. {
  204.     return( NGetTrapAddress( tNumber, tType ) 
  205.     != GetTrapAddress( _Unimplemented ) );
  206. }
  207.  
  208.  
  209. /********** GetSysConfig */
  210.  
  211. static void GetSysConfig_( void )
  212. {   
  213.     OSErr        ignoreError;
  214.     long         tempLong;
  215.     SysEnvRec    environs;
  216.     short        myBit;
  217.  
  218.  
  219.     gAppResourceFile = CurResFile();  /* set app resource fork ID */
  220.  
  221.     /* Check to see if Gestalt Manager is supported */
  222.     gSysConfig.hasGestalt = TrapAvailable_( _Gestalt, ToolTrap );
  223.     if( !gSysConfig.hasGestalt )
  224.         /* Something has got to be wrong */
  225.         FnErr_DisplayStrID( BAD_SYS, TRUE );
  226.     else
  227.     {
  228.         /* Determine various system configuration checks */
  229.  
  230.         /* Check to see if WaitNextEvent is supported */
  231.         gSysConfig.hasWNE = TrapAvailable_( _WaitNextEvent, ToolTrap );
  232.         
  233.         /* Check for Color Capability */
  234.         ignoreError = Gestalt( gestaltQuickdrawVersion, &tempLong );
  235.         gSysConfig.hasColorQD = ( tempLong != gestaltOriginalQD );
  236.         
  237.         /* Check to see if AppleEvents are supported in OS */
  238.         gSysConfig.hasAppleEvents = ( Gestalt( gestaltAppleEventsAttr,
  239.             &tempLong ) == noErr );
  240.  
  241.         /* Check for Edition Manager */
  242.         gSysConfig.hasEditionMgr = ( Gestalt( gestaltEditionMgrAttr,
  243.             &tempLong ) == noErr );
  244.         if( gSysConfig.hasEditionMgr )
  245.             if( InitEditionPack() != noErr )
  246.                 gSysConfig.hasEditionMgr = false;
  247.                 
  248.         /* Check for Help Manager */
  249.         ignoreError = Gestalt( gestaltHelpMgrAttr, &tempLong );
  250.         myBit = gestaltHelpMgrPresent;
  251.         gSysConfig.hasHelpMgr =
  252.             BitTst( &tempLong, 31 - myBit );
  253.             
  254.         /* Determine and Check OS Version */
  255.         gSysConfig.sysVersion = 0.0;
  256.         ignoreError = Gestalt( gestaltSystemVersion, &tempLong );
  257.         gSysConfig.sysVersion = tempLong;
  258.         if( MIN_SYS_VERSION > gSysConfig.sysVersion )
  259.             FnErr_DisplayStrID( BAD_SYS, TRUE );
  260.     }
  261. }
  262.  
  263.  
  264. /********** MenuBarInit    */
  265.  
  266. void MenuBarInit_( void )
  267. {
  268.     Handle     myMenuBar;
  269.     MenuHandle helpMenu;
  270.     OSErr      err;
  271.  
  272.     myMenuBar = GetNewMBar( BASE_RES ) ;
  273.     if ( myMenuBar == NIL_PTR )
  274.         FnErr_DisplayStrID( N0_RESOURCE, TRUE );
  275.     SetMenuBar( myMenuBar );
  276.     
  277.     if ( ( gAppleMenu = GetMHandle( APPLE_MENU ) ) == NIL_PTR )
  278.         FnErr_DisplayStrID( N0_RESOURCE, TRUE );
  279.     if ( ( gFileMenu = GetMHandle( FILE_MENU ) ) == NIL_PTR )
  280.         FnErr_DisplayStrID( N0_RESOURCE, TRUE );
  281.     if ( ( gEditMenu = GetMHandle( EDIT_MENU ) ) == NIL_PTR )
  282.         FnErr_DisplayStrID( N0_RESOURCE, TRUE );
  283.         
  284.     AddResMenu( gAppleMenu, 'DRVR' );
  285.     DrawMenuBar();
  286.     
  287.     if( gSysConfig.hasHelpMgr )
  288.     {
  289.         err = HMGetHelpMenuHandle( &helpMenu );
  290.         if( err == noErr )
  291.         {
  292.             if( helpMenu != nil )
  293.             {
  294.                  AppendMenu( helpMenu, HELP_MENU );   
  295.             }
  296.         }
  297.     }
  298. }
  299.  
  300.  
  301. /********** SetUpDragRect */
  302.  
  303. void SetUpDragRect_( void )
  304. {
  305.     gDragRect = qd.screenBits.bounds;
  306.     gDragRect.left += DRAG_THRESHOLD;
  307.     gDragRect.right -= DRAG_THRESHOLD;
  308.     gDragRect.bottom -= DRAG_THRESHOLD;
  309. }
  310.  
  311.  
  312. /********** MainLoop */
  313.  
  314. void MainLoop_( void )
  315. {
  316.     gDone = FALSE;
  317.     while( gDone == FALSE )
  318.     {
  319.         HandleEvent_();
  320.     }
  321. }
  322.  
  323.  
  324. /********** HandleEvent */
  325.  
  326. void HandleEvent_( void )
  327. {
  328.     char    theChar;
  329.     GrafPtr oldPort;
  330.     Point   displayPoint;
  331.     
  332.     if ( gSysConfig.hasWNE )
  333.         WaitNextEvent( everyEvent, &gTheEvent, MIN_SLEEP,
  334.             NIL_MOUSE_REGION );
  335.     else
  336.     {
  337.         SystemTask();
  338.         GetNextEvent( everyEvent, &gTheEvent );
  339.     }
  340.  
  341.     switch ( gTheEvent.what )
  342.     {
  343.         case mouseDown: 
  344.             HandleMouseDown_();
  345.             break;
  346.         case mouseUp:
  347.             // this application doesn't use mouseUp events
  348.             break;
  349.         case keyDown:
  350.         case autoKey:
  351.             theChar = gTheEvent.message & charCodeMask;
  352.             if (( gTheEvent.modifiers & cmdKey ) != 0)
  353.             {
  354.                 AdjustMenus_(); 
  355.                 HandleMenuChoice_( MenuKey( theChar ) );
  356.             }
  357.             else
  358.             {
  359.                 /* Handle text from keyboard */
  360.             }
  361.             break;
  362.         case updateEvt:
  363.             if ( !IsDAWindow_( (WindowPtr)gTheEvent.message ) )
  364.             {
  365.                 /* Handle update event */
  366.                 MyDoUpdateWindow( (WindowPtr)gTheEvent.message );
  367.              }
  368.             break;
  369.         case diskEvt:
  370.             // most applications don't need to worry about diskEvt's
  371.              break;
  372.         case activateEvt:
  373.             if ( !IsDAWindow_( (WindowPtr)gTheEvent.message ) )
  374.             {
  375.                 if ( gTheEvent.modifiers & activeFlag )
  376.                 {
  377.                     /* Handle activate event. */
  378.                     MyDoActivateWindow((WindowPtr)gTheEvent.message);
  379.                 }
  380.                 else
  381.                 {
  382.                     /* Handle deactivate event. */
  383.                     MyDoDeactivateWindow((WindowPtr)gTheEvent.message);
  384.                 }
  385.             }
  386.             break;
  387.         case osEvt:
  388.             // this application doesn't support operating sys events
  389.             break;
  390.         case nullEvent:
  391.             // ignore
  392.             break;
  393.         case kHighLevelEvent:
  394.             // need to #include <Events.h> to define kHighLevelEvent
  395.             FnAE_DoHighLevelEvent( &gTheEvent );
  396.             break;
  397.     }
  398. }
  399.  
  400.  
  401. /********** HandleMouseDown */
  402.  
  403. void HandleMouseDown_( void )
  404. {
  405.     WindowPtr   whichWindow;
  406.     short int   thePart;
  407.     long int    menuChoice;    
  408.     Point       theLocation;
  409.     
  410.     thePart = FindWindow( gTheEvent.where, &whichWindow );
  411.     switch ( thePart )
  412.     {
  413.         case inMenuBar:
  414.             AdjustMenus_();
  415.             menuChoice = MenuSelect( gTheEvent.where );
  416.             HandleMenuChoice_( menuChoice );
  417.             break;
  418.         case inSysWindow: 
  419.             SystemClick( &gTheEvent, whichWindow );
  420.             break;
  421.         case inContent:
  422.             if( whichWindow != FrontWindow() )
  423.                 SelectWindow( whichWindow );
  424.             else if( !IsDAWindow_( (WindowPtr)gTheEvent.message ) )
  425.                 /* Handle click in window content */ 
  426.                 MyDoContent( whichWindow, &gTheEvent );
  427.             break;
  428.         case inDrag:
  429.             if( whichWindow != FrontWindow() )
  430.             {
  431.                 SelectWindow( whichWindow );
  432.                 DragWindow( whichWindow, gTheEvent.where, &gDragRect );
  433.             }
  434.             else
  435.                 DragWindow( whichWindow, gTheEvent.where, &gDragRect );
  436.             break;
  437.         case inGrow:
  438.             // not used in this application
  439.             break;
  440.         case inGoAway:
  441.             theLocation = gTheEvent.where;
  442.             GlobalToLocal( &theLocation );
  443.             if( TrackGoAway( whichWindow, theLocation ) )
  444.                 DisposeWindow( whichWindow );
  445.             break;
  446.         case inZoomIn:
  447.         case inZoomOut:
  448.             // not used in this application
  449.             break;
  450.     }
  451. }
  452.  
  453.  
  454. /********** AdjustMenus */
  455.  
  456. void AdjustMenus_( void )
  457. {
  458.     WindowPtr currentWindow;
  459.  
  460.     if (IsDAWindow_( FrontWindow() ) )
  461.     {
  462.         EnableItem( gEditMenu, UNDO );
  463.         EnableItem( gEditMenu, CUT );
  464.         EnableItem( gEditMenu, COPY );
  465.         EnableItem( gEditMenu, PASTE );
  466.         EnableItem( gEditMenu, CLEAR );
  467.     }
  468.     else
  469.     {
  470.         DisableItem( gEditMenu, UNDO );
  471.         DisableItem( gEditMenu, CUT );
  472.         DisableItem( gEditMenu, COPY );
  473.         DisableItem( gEditMenu, PASTE );
  474.         DisableItem( gEditMenu, CLEAR );
  475.     }
  476.         
  477.     if ( ( currentWindow = FrontWindow() ) == NIL_PTR )
  478.         DisableItem( gFileMenu, CLOSE );
  479.     else
  480.         EnableItem( gFileMenu, CLOSE );
  481. }
  482.  
  483.  
  484. /********** IsDAWindow */
  485.  
  486. int IsDAWindow_( WindowPtr whichWindow )
  487. {
  488.     if ( whichWindow == NIL_PTR )
  489.         return( FALSE );
  490.     else /* DA windows have negative windowKinds */
  491.         return( ( (WindowPeek)whichWindow )->windowKind < 0 );
  492. }
  493.  
  494.  
  495. /********** HandleMenuChoice */
  496.  
  497. void HandleMenuChoice_( long int menuChoice )
  498. {
  499.     int    theMenu;
  500.     int    theItem;
  501.     
  502.     if ( menuChoice != 0 )
  503.     {
  504.         theMenu = HiWord( menuChoice );
  505.         theItem = LoWord( menuChoice );
  506.         switch ( theMenu )
  507.         {
  508.             case APPLE_MENU :
  509.                 HandleAppleChoice_( theItem );
  510.                 break;
  511.             case FILE_MENU :
  512.                 HandleFileChoice_( theItem );
  513.                 break;
  514.             case EDIT_MENU :
  515.                 HandleEditChoice_( theItem );
  516.                 break;
  517.             case kHMHelpMenuID :
  518.                 MyHelpDialog();
  519.                 break;
  520.         }
  521.         HiliteMenu( 0 );
  522.     }
  523. }
  524.  
  525.  
  526. /********** HandleAppleChoice */
  527.  
  528. void HandleAppleChoice_( int theItem )
  529. {
  530.     Str255  accName;
  531.     int     accNumber;
  532.     
  533.     switch ( theItem )
  534.     {
  535.         case ABOUT : 
  536.             MyAboutDialog();
  537.             break;
  538.         default :
  539.             GetItem( gAppleMenu, theItem, accName );
  540.             accNumber = OpenDeskAcc( accName );
  541.             break;
  542.     }
  543. }
  544.  
  545.  
  546. /********** HandleFileChoice */
  547.  
  548. void HandleFileChoice_( int theItem )
  549. {
  550.     WindowPtr   whichWindow;
  551.  
  552.     switch ( theItem )
  553.     {
  554.         case NEW :
  555.             NewWindow_();
  556.             break;
  557.         case CLOSE :
  558.             if ( ( whichWindow = FrontWindow() ) != NIL_PTR )
  559.                 DisposeWindow( whichWindow );
  560.             break;
  561.         case QUIT :
  562.             Quit_();
  563.             break;
  564.     }
  565. }
  566.  
  567.  
  568. /********** HandleEditChoice */
  569.  
  570. void HandleEditChoice_( int theItem )
  571. {
  572.     if( SystemEdit( theItem - 1 ) == 0 )
  573.     {
  574.         /* Add Edit menu switch statement here */
  575.     }
  576. }
  577.  
  578.  
  579. /********** NewWindow */
  580.  
  581. void NewWindow_( void )
  582. {
  583.     MyCreateWindow( BASE_RES, NIL_PTR, (WindowPtr)MOVE_TO_FRONT,
  584.         WIND_TOP, WIND_LEFT, WIND_OFFSET, N0_RESOURCE );
  585. }
  586.  
  587.  
  588. /********** Quit */
  589.  
  590. void Quit_( void )
  591. {
  592.     gDone = TRUE;
  593. }
  594.  
  595.  
  596. /**********************************************************************
  597.  
  598.     Main.r
  599.  
  600. ***********************************************************************/
  601.  
  602. #include <Types.r>
  603.  
  604. resource 'MBAR' (400, "Main MBAR") {
  605.     {    /* array MenuArray: 3 elements */
  606.         /* [1] */
  607.         400,
  608.         /* [2] */
  609.         401,
  610.         /* [3] */
  611.         402
  612.     }
  613. };
  614.  
  615. resource 'MENU' (400, "Apple") {
  616.     400,
  617.     textMenuProc,
  618.     0x7FFFFFFD,
  619.     enabled,
  620.     apple,
  621.     {    /* array: 2 elements */
  622.         /* [1] */
  623.         "About Application...", noIcon, noKey, noMark, plain,
  624.         /* [2] */
  625.         "-", noIcon, noKey, noMark, 1
  626.     }
  627. };
  628.  
  629. resource 'MENU' (401, "File") {
  630.     401,
  631.     textMenuProc,
  632.     allEnabled,
  633.     enabled,
  634.     "File",
  635.     {    /* array: 3 elements */
  636.         /* [1] */
  637.         "New", noIcon, "N", noMark, plain,
  638.         /* [2] */
  639.         "Close", noIcon, "W", noMark, plain,
  640.         /* [3] */
  641.         "Quit", noIcon, "Q", noMark, plain
  642.     }
  643. };
  644.  
  645. resource 'MENU' (402, "Edit", preload) {
  646.     402,
  647.     textMenuProc,
  648.     0x0,
  649.     enabled,
  650.     "Edit",
  651.     {    /* array: 6 elements */
  652.         /* [1] */
  653.         "Undo", noIcon, "Z", noMark, plain,
  654.         /* [2] */
  655.         "-", noIcon, noKey, noMark, plain,
  656.         /* [3] */
  657.         "Cut", noIcon, "X", noMark, plain,
  658.         /* [4] */
  659.         "Copy", noIcon, "C", noMark, plain,
  660.         /* [5] */
  661.         "Paste", noIcon, "V", noMark, plain,
  662.         /* [6] */
  663.         "Clear", noIcon, noKey, noMark, plain
  664.     }
  665. };
  666.  
  667.  
  668. /**********************************************************************
  669.  
  670.     MainBalloons.r
  671.  
  672. ***********************************************************************/
  673.  
  674. #include <Types.r>
  675. #include <BalloonTypes.r>
  676.  
  677. resource 'hmnu' (400, "Apple", purgeable) {
  678. /* header component */
  679.   HelpMgrVersion,    /* version of Help Manager */
  680.   hmDefaultOptions,  /* options */
  681.   0,                 /* balloon definition function */
  682.   0,                 /* variation code */
  683.   
  684. /* missing-items component */
  685.   HMSkipItem {
  686.     /* no missing items, so skip to menu-title component */
  687.     },
  688.  
  689. /* BEGIN */ {
  690.  
  691. /* menu-title component */
  692.   HMSkipItem {
  693.     /* Apple menu has default help balloons */
  694.     },
  695.     
  696. /* first menu-item component: About */
  697.   HMStringItem {
  698.     /* enabled */
  699.     "Displays information about this application.",
  700.     /* dimmed by application */
  701.     "",
  702.     /* checked */
  703.     "",
  704.     /* marked */
  705.     "",
  706.     },
  707.     
  708. /* END */ }
  709. };
  710.  
  711. resource 'hmnu' (401, "File", purgeable) {
  712. /* header component */
  713.   HelpMgrVersion,    /* version of Help Manager */
  714.   hmDefaultOptions,  /* options */
  715.   0,                 /* balloon definition function */
  716.   0,                 /* variation code */
  717.   
  718. /* missing-items component */
  719.   HMSkipItem {
  720.     /* no missing items, so skip to menu-title component */
  721.     },
  722.  
  723. /* BEGIN */ {
  724.  
  725. /* menu-title component */
  726.   HMStringItem {
  727.     /* enabled */
  728.     "File menu\n\nUse this menu to open documents or quit "
  729.     "this application.",
  730.     /* dimmed by application */
  731.     "",
  732.     /* dimmed by system (alerts or modal dialogs) */
  733.     "File menu\n\nUse this menu to open documents or quit "
  734.     "this application. Not available because there is a dialog box "
  735.     "on the screen.",
  736.     /* all items dimmed by system */
  737.     "This item is not available because there is a dialog "
  738.     "box on the screen.",
  739.     },
  740.     
  741. /* first menu-item component: New */
  742.   HMStringItem {
  743.     /* enabled */
  744.     "Creates new document window.",
  745.     /* dimmed by application */
  746.     "",
  747.     /* checked */
  748.     "",
  749.     /* marked */
  750.     "",
  751.     },
  752.  
  753. /* second menu-item component: Close */
  754.   HMStringItem {
  755.     /* enabled */
  756.     "Closes current document window.",
  757.     /* dimmed by application */
  758.     "Closes current document window. Not available now "
  759.     "because the application does not currently have an "
  760.     "open window.",
  761.     /* checked */
  762.     "",
  763.     /* marked */
  764.     "",
  765.     },
  766.  
  767. /* third menu-item component: Quit */
  768.   HMStringItem {
  769.     /* enabled */
  770.     "Quits this application.",
  771.     /* dimmed by application */
  772.     "",
  773.     /* checked */
  774.     "",
  775.     /* marked */
  776.     "",
  777.     },
  778.     
  779. /* END */ }
  780. };
  781.  
  782. resource 'hmnu' (402, "Edit", purgeable) {
  783. /* header component */
  784.   HelpMgrVersion,    /* version of Help Manager */
  785.   hmDefaultOptions,  /* options */
  786.   0,                 /* balloon definition function */
  787.   0,                 /* variation code */
  788.   
  789. /* missing-items component */
  790.   HMSkipItem {
  791.     /* no missing items, so skip to menu-title component */
  792.     },
  793.  
  794. /* BEGIN */ {
  795.  
  796. /* menu-title component */
  797.   HMStringItem {
  798.     /* enabled */
  799.     "Edit menu\n\nUse this menu to manipulate text.",
  800.     /* dimmed by application */
  801.     "Edit menu\n\nUse this menu to manipulate text. "
  802.     "Not available because there is nothing to edit.",
  803.     /* dimmed by system (alerts or modal dialogs) */
  804.     "Edit menu\n\nUse this menu to manipulate text. "
  805.     "Not available because there is a dialog box on "
  806.     "the screen.",
  807.     /* all items dimmed by system */
  808.     "This item is not available because there is a dialog "
  809.     "box on the screen.",
  810.     },
  811.     
  812. /* first menu-item component: Undo */
  813.   HMStringItem {
  814.     /* enabled */
  815.     "Cancels your last edit.",
  816.     /* dimmed by application */
  817.     "Cancels your last edit. Not available because "
  818.     "application doesn't support this function.",
  819.     /* checked */
  820.     "",
  821.     /* marked */
  822.     "",
  823.     },
  824.     
  825. /* second menu-item component: Divider */
  826.   HMSkipItem {
  827.     /* no help balloons for divider lines */
  828.     },
  829.     
  830. /* third menu-item component: Cut */
  831.   HMStringItem {
  832.     /* enabled */
  833.     "Cuts selected text to the Clipboard.",
  834.     /* dimmed by application */
  835.     "Cuts selected text to the Clipboard. Not available now "
  836.     "because no text is selected.",
  837.     /* checked */
  838.     "",
  839.     /* marked */
  840.     "",
  841.     },
  842.  
  843. /* forth menu-item component: Copy */
  844.   HMStringItem {
  845.     /* enabled */
  846.     "Copies selected text to the Clipboard.",
  847.     /* dimmed by application */
  848.     "Copies selected text to the Clipboard. Not available now "
  849.     "because no text is selected.",
  850.     /* checked */
  851.     "",
  852.     /* marked */
  853.     "",
  854.     },
  855.  
  856. /* fifth menu-item component: Paste */
  857.   HMStringItem {
  858.     /* enabled */
  859.     "Inserts selected text from the Clipboard.",
  860.     /* dimmed by application */
  861.     "Inserts selected text from the Clipboard. Not available "
  862.     "now because there is no text currently in the Clipboard.",
  863.     /* checked */
  864.     "",
  865.     /* marked */
  866.     "",
  867.     },
  868.  
  869. /* sixth menu-item component: Clear */
  870.   HMStringItem {
  871.     /* enabled */
  872.     "Deletes selected text.",
  873.     /* dimmed by application */
  874.     "Deletes selected text. Not available now "
  875.     "because no text is selected.",
  876.     /* checked */
  877.     "",
  878.     /* marked */
  879.     "",
  880.     },
  881.     
  882. /* END */ }
  883. };
  884.  
  885. resource 'hmnu' (kHMHelpMenuID, "Help", purgeable)
  886. {
  887.     HelpMgrVersion, 0, 0, 0,  /* header component             */
  888.     HMSkipItem{               /* missing-items component      */
  889.         /* no missing items, skip to first appended menu-item */
  890.         /* component                                          */
  891.         },
  892.     {   /* first menu-item component */
  893.         HMStringResItem{  /* use an 'STR#' for help messages  */
  894.         800, 1,  /* 'STR#' res ID, index when item is enabled */
  895.         800, 2,  /* 'STR#' res ID, index when item is dimmed  */
  896.         800, 3,  /* 'STR#' res ID, index when item is checked */
  897.         0, 0     /* item cannot be marked */
  898.         },
  899.     }
  900. };
  901.  
  902. resource 'STR#' (800, "Help menu item strings")
  903. {
  904.     {
  905.         /* array StringArray: six elements */
  906.         /* [1] enabled help command */
  907.         "Provides help for this application.";
  908.         /* [2] dimmed help command */
  909.         "Provides help for this application.";
  910.         /* [3] checked help command */
  911.         "Provides help for this application.";
  912.     }
  913. };
  914.  
  915. // End of File
  916.